package com.example.demo.controller;
import com.example.demo.model.User;
import com.example.demo.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;

/**
 * @author Administrator 高欣月
 */

    @Api(tags = "员工信息")
    @RestController
    @RequestMapping("/swagger1")
    public class SwaggerController {
        @Autowired
        private IUserService userService;
    @CrossOrigin
    @ApiOperation(value="对人员信息的添加方法")
    @PostMapping("/insertuser")
    public int insertUser(@RequestBody User user){
        System.out.println("进入添加人员接口" );
        return userService.insertUser(user);
    }

    @PostMapping("/getAll")
    public List<User> getAllUser(@RequestBody User user)
    {
        System.out.println("进入查询方法");
        List<User> listUser=userService.getAllUser(user);
        return listUser;
    }
    @PostMapping("/editUser")
    public int EditUser(@RequestBody User user){
        System.out.println("添加修改方法");
        return userService.updateUser(user);
}
    @GetMapping("/delUser")
    public int Delete(int ygid){
        System.out.println("进入删除方法");
        int returnValues=0;
        if(ygid!=0){
            User user=new User();
            user.setYgid(ygid);
        returnValues=userService.deleteUser(user);
        }
        return returnValues;
    }

    @GetMapping("/getOne")
    public User getUser(int ygid){
        User user=new User();
        System.out.println("进入单条查询方法");
        if(ygid!=0){
            User user1=new User();
            user1.setYgid(ygid);
            user=userService.getUser(user1);
            System.out.println("返回的数据集合为:"+user.getName());
        }
        return user;
    }
}
